<script>
	import { http } from 'uview-plus'
	export default {
		onLaunch:async function() {
			console.log('App Launch')
			if(uni.getStorageSync('token')){
				this.get_shopping_List()
			}
		},
		onShow: function() {
			console.log('App Show')
		},
		onHide: function() {
			console.log('App Hide')
		},
		methods:{
			async get_shopping_List(callback){
				await http.get('/shop/user/cart').then(res => {
						uni.setStorageSync('shoppingList',res.items)
						var totalMoney = 0;
						var num = 0
						for( var i = 0 ; i < res.items.length ; i++ ){
							totalMoney = totalMoney+(res.items[i].join_price * res.items[i].num)
							num += res.items[i].num
						}
						uni.setStorageSync('totalMoney',totalMoney);									   
						uni.setStorageSync('car_num',num);									   
				})
			}
		}

	}
</script>

<style lang="scss">
	/* 注意要写在第一行，同时给style标签加入lang="scss"属性 */
	@import "uview-plus/index.scss";
	view{
		font-family: 思源黑体;
	}
	.clear{
		clear: both;
	}
</style>
